<%@page import="javax.sound.midi.MidiDevice.Info"%>
<%@ page import="java.net.URLEncoder"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.finple.DBConnection"%>
<%@ page import="com.finple.MeetingInfoVo"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%
	request.setCharacterEncoding("UTF-8");

	String initiatorAlias, title, location, password, description, initiatorEmail;
	
	title = request.getParameter("title");
	location = request.getParameter("location");
	password = "1234";
	description = request.getParameter("description");
	initiatorAlias = request.getParameter("initiatorAlias");
	initiatorEmail = request.getParameter("initiatorEmail");

	MeetingInfoVo info = new MeetingInfoVo();
	info.setTitle(title);
	info.setPassword(password);
	info.setLocation(location);
	info.setDescription(description);
	info.setInitiatorAlias(initiatorAlias);
	info.setInitiatorEmail(initiatorEmail);
	info.setPollTime("-");
	info.setPollId(16);

	//해당 identifier가 중복되는지 확인하고 중복되면 다른 랜덤 문자열을 입력한다.
	if(!info.hasNull()) {
		while (DBConnection.GetInst().getMeetingData(info.getPollId()) != null) {
			System.out.println("poll_id가 중복되어 다른 id로 변경");
			info.setPollId(16);
		}
		DBConnection.GetInst().insertMeetingData(info);
	}
%>
</head>
<body>
	<form class="form-container" action="/Finple/index.jsp" method="post">
		<div class="form-contain" align="center">
			<div class="process">
				<ol class="inline">
					<li><a href="/Finple/data/create_step1.jsp">Schedule an event</a></li>
					<li>▶</li>
					<li><a href="/Finple/data/create_step2.jsp">Time proposals</a></li>
					<li>▶</li>
					<li><a href="/Finple/data/create_step3.jsp">Settings</a></li>
					<li>▶</li>
					<li><a href="/Finple/data/create_step4.jsp"><span class="text-success">Invite</span></a></li>
				</ol>
			</div>
			<div id="header">
				<div id="title">
					<h2 align="center">
						<font color="#8B5927">Invite</font>
					</h2>
				</div>
			</div>
			<div align="center">
				<p>친구를 나의 일정에 초대하세요</p>
				<p>Link : <a href="http://203.237.183.109/Finple/data/tableview.jsp?id=<%=info.getPollId()%>">http://203.237.183.109/Finple/<%=info.getPollId()%></a></p>
			</div>
			 
			<div>
				<div class="submit-container">
					<button type="submit" class="btn btn-success">Finish</button>
				</div>
			</div>
		</div>
	</form>
</body>
</html>